const sequelize = require('../config/connect.js')//引入数据库连接文件
const config = require('../config/config.js')//引入数据库配置文件
const customer = require('./customer.js')//引入客户表
const room = require('./room.js')//引入房间表
const waiter = require('./waiter.js')//引入清洁工表
const { Op, Model, DataTypes } = require('sequelize')//引入nodejs的orm模型文件

class myorder extends Model{} //订单信息表

myorder.init({
    orderNumber:{
        type:DataTypes.STRING(32),
        primaryKey:true,
        comment:'订单号'
    },
    orderStatus:{
        type:DataTypes.STRING(32),
        allowNull:false,
        comment:'订单状态'
    },
    customerIdCard:{
        type:DataTypes.STRING(32),
        allowNull:false,
        comment:'客户身份证',
        references:{
            model:customer,
            key:'customerIdCard'
        }
    },
    roomNumber:{
        type:DataTypes.STRING(32),
        allowNull:false,
        comment:'入住房间号',
        references:{
            model:room,
            key:'roomNumber'
        }
    },
    checkInTime:{
        type:DataTypes.DATE,
        allowNull:false,
        comment:'入住时间'
    },
    checkOutTime:{
        type:DataTypes.DATE,
        allowNull:false,
        comment:'离店时间'
    },
    totalMoney:{
        type:DataTypes.INTEGER,
        allowNull:false,
        comment:'需付金额'
    },
    remarks:{
        type:DataTypes.STRING(32),
        allowNull:true
    }
},{
    sequelize,
    charset:config.charset,
    timestamps:false,
    freezeTableName:true,
    modelName:'myorder'
})

module.exports = myorder;